import java.util.Scanner;

public class BruteForceSolution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int q = in.nextInt();
        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextLong();
        }
        while (q != 0) { // 注意 while 处理多个 case
            int left = in.nextInt();
            int right = in.nextInt();
            long sum = 0;
            for (int i = left - 1; i < right; i++) {
                sum += nums[i];
            }
            System.out.println(sum);
            q--;
        }
    }
}
